/**
 * Description:
 * Class Name:Operation
 * Date:2022/2/12 18:13
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第6章_面向对象_下._6_9_枚举类._6_9_5_包含抽象方法的枚举类;

public enum Operation {
    PLUS{
        @Override
        public double eval(double x, double y) {
            return x + y;
        }
    },
    MINUS{
        @Override
        public double eval(double x, double y) {
            return x - y;
        }
    },
    TIMES{
        @Override
        public double eval(double x, double y) {
            return x * y;
        }
    },
    DIVIDE{
        @Override
        public double eval(double x, double y) {
            return x / y;
        }
    }
    ;
    public abstract double eval(double x, double y);

    public static void main(String[] args) {
        System.out.println(Operation.PLUS.eval(3, 4));
        System.out.println(Operation.MINUS.eval(3, 4));
        System.out.println(Operation.TIMES.eval(3, 4));
        System.out.println(Operation.DIVIDE.eval(3, 4));
    }
}
